/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view.web;

import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import model.Operator;

/**
 *
 * @author camil
 */
public class WebTabsPanel extends view.base.TabsPanel {

    public final static Logger EXCEPTIONLOGGER = Logger.getLogger("exception logger");
    public WebTabsPanel(String _operatorsFile) {
        super(_operatorsFile);
    }

    @Override
    protected void loadStartOperators() throws Exception {
        //TODO: add load operators 
        final URL url;
        try {
            url = new URL(operatorsFile);
            //System.out.println("URL:\n" + url.getProtocol() + "\n" + url.getPort() + "\n" + url.getHost() + "\n" + url.getFile() + "\n" + url.getPath());
            InputStream stream = url.openStream();
            
            InputStreamReader file = new InputStreamReader(stream);
            operators = Operator.loadOperators(file);
        } catch (Exception e) {
            //TODO: obsługa braku pobrania operatorów
            String message="exception "+e.getMessage();
            EXCEPTIONLOGGER.finest(message);
            JOptionPane.showMessageDialog(this, "Problem occurred\n"+e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        }
    }
}
